package com.mazaiting.mail.controller;

import com.mazaiting.common.core.constant.ExMessageConst;
import com.mazaiting.common.core.domain.result.Result;
import com.mazaiting.common.core.ex.exceptions.BaseException;
import com.mazaiting.mail.dto.MailAlarmDTO;
import com.mazaiting.mail.service.IMsgEmailSendService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotBlank;

/**
 * 邮件消息发送表
 *
 * @author mazaiting
 * @since 2022-04-16
 */
@Validated
@RestController
@RequestMapping("mail/v1/send")
@RequiredArgsConstructor
public class MsgEmailSendController {

    private final IMsgEmailSendService msgEmailSendService;

    /**
     * 预警邮件
     * @param mailAlarmDTO 预警邮件
     * @return true: 邮件发送成功; false: 邮件发送失败
     */
    @PostMapping("alarm")
    public boolean alarm(MailAlarmDTO mailAlarmDTO) throws BaseException {
        return msgEmailSendService.alarm(mailAlarmDTO);
    }

    /**
     * 发送单个邮件服务
     * 可以自定义标题以及内容
     * @return  是否成功发送
     */
    @PostMapping("/send")
    public Result<String> send(
//            @NotNull(message = ExMessageConst.NOT_EMPTY_EMAIL)
//            @RequestBody
//            MailVO mailVO
    ){

        //默认失败
        return Result.failed();
    }

    /**
     * 发送验证码
     * @param to 接受者
     * @param code 验证码
     * @return 是否成功发送
     */
    @PostMapping("/sendCode")
    public Result<String> sendCode(
            @NotBlank(message = ExMessageConst.PARAM_NULL) String to,
            @NotBlank(message = ExMessageConst.PARAM_NULL) String code
    ){

        //默认失败
        return Result.failed();
    }

    /**
     * 发送html邮件
     * @return 是否成功发送
     */
    @PostMapping("/sendHtmlMail")
    public Result<String> sendHtmlMail(
//            @NotNull(message = ExMessageConst.NOT_EMPTY_EMAIL) @RequestBody MailVO mailVO
    ){
        //默认失败
        return Result.failed();
    }
}
